

var EXPORTED_SYMBOLS = ["Storage"];

let Storage = (function() {
    "use strict";

    return {
        __global_map: new Map(),
        __specific_map: new Map(),

        has(name) {
            return this.__global_map.has(name);
        },

        get(name) {
            return this.__global_map.get(name);
        },

        set(name, value) {
            this.__global_map.set(name, value);
        },

        clear(name) {
            this.__global_map.delete(name);
        },
        
        clearAll() {
            this.__global_map.clear();
        },

        getSpecific(wid, name) {
            if (!this.__specific_map.has(wid))
                return null;
            return this.__specific_map.get(wid).get(name);
        },
        
        setSpecific(wid, name, value) {
            if (!this.__specific_map.has(wid))
                this.__specific_map.set(wid, new Map());
            this.__specific_map.get(wid).set(name, value);
        },

        clearSpecific(wid, name) {
            let m = this.__specific_map.get(wid);
            if (m) {
                m.delete(name);
                if (!m.size)
                    this.__specific_map.delete(wid);
            }
        }
    };
}) ();
